(function(){
    //星星评分
    function Star(star){
        var temp = 5;
        for(var i = 0, len = star.length; i < len; i++){
            star[i].index = i;
            //star[i].onmouseover = function(){
            //    clear();
            //    for(var j = 0; j < this.index + 1; j++){
            //        star[j].style.backgroundImage ="../img/ass_star.png";
            //    }
            //};
            //star[i].onmouseout = function(){
            //    for(var j = 0; j < this.index + 1; j++){
            //        star[j].style.backgroundImage ="../img/bright_star.png";
            //    }
            //    current(temp);
            //};
            star[i].onclick = function(){
                console.log(1)
                clear();
                temp = this.index + 1;
                $(this).parent().parent().children("i").text(temp);
                current(temp);
                $(this).parent().children("input").val(temp)

            }
        }
        //清除所有
        function clear(){
            for(var i = 0, len = star.length; i < len; i++){
                star[i].style.background ="url('./Public/img/ass_icon_04.png') no-repeat";
            }
        }
        //显示当前第几颗星
        function current(temp){
            for(var i = 0; i < temp; i++){
                star[i].style.background ="url('./Public/img/bright_star.png') no-repeat";
            }

        }
    }



    //todo 获取页面中有几个商品评价  添加星星评分方法
    var length=$(".wrapper").length;
    for(var i=0;i<length;i++){
        Star($(".wrapper"+i+" a"));
    }
})();
